from time import sleep


class Person:
    """Person类"""

    def __init__(self, name, age):
        self.name = name
        self.age = age

    def speak(self):
        print("{0} 的年龄：{1}".format(self.name, self.age))


class Student(Person):
    """Student类"""

    def __init__(self, name, age, school, my_id):
        super(Student, self).__init__(name, age)
        self.school = school
        self.my_id = my_id

    def speak(self):
        print("Student Info:{0} {1} {2} {3}".format(self.name, self.age, self.school, self.my_id))

    def run(self, v, times):
        print("{0}跑的距离：{1}".format(self.name, v * times))


class CollegeStudent(Student):
    """CollegeStudent类"""

    def __init__(self, name, age, school, my_id, language):
        super(CollegeStudent, self).__init__(name, age, school, my_id)
        self.language = language

    def speak(self):
        print("{0} Info:{1} {2} {3} {4} {5}".format(self.__class__.__name__,
                                                    self.name,
                                                    self.age,
                                                    self.school,
                                                    self.my_id,
                                                    self.language))

    def coding(self):
        msg = "I am coding"
        while 1:
            if 10 == msg.count("."):
                break
            msg += "."
            print(msg)
            sleep(1)

    def coding2(self):
        print("I am coding", end="")
        for i in range(10):
            print(".", end="")
            sleep(1)


if __name__ == '__main__':
    p = Person("zhouruifu01", 18)
    p.speak()

    student = Student("zhouruifu", 20, "Tencent", 100000)
    student.speak()
    student.run(1, 100)

    # 调用父类方法
    super(Student, student).speak()
    # 还是p对象自己
    p.speak()

    college_student = CollegeStudent("zhouruifu02", 22, "腾讯", 100001, "Chinese")
    college_student.speak()
    college_student.coding()
    college_student.coding2()
